package com.kemai.designmode.ui

import android.os.Bundle
import com.kemai.common.adapter.ItemClickListener
import com.kemai.common.ui.BaseActivity
import com.kemai.designmode.R
import com.kemai.designmode.entry.Fruit
import com.kemai.designmode.entry.FruitType
import com.kemai.designmode.factory.static.StaticFactory
//静态工厂模式调用（将多个对象通过一个工厂去提供）
class StaticFactoryActivity : BaseActivity(), ItemClickListener {
    private val studyContent = arrayOf("获取苹果","获取香蕉","获取桔子")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_common_content)
        findViewById()
        setTiTle("简单工厂模式")
        setAdapterContent(studyContent,SimpleFactoryActivity@this,SimpleFactoryActivity@this)

    }
    override fun itemClick(position: Int) {
        var fruit:Fruit? = null
        when(position){
            0->{
                fruit = StaticFactory.instance?.getFruit(FruitType.appleType)

            }
            1->{
                fruit = StaticFactory.instance?.getFruit(FruitType.bananaType)

            }
            2->{
                fruit = StaticFactory.instance?.getFruit(FruitType.orangeType)

            }

        }
        fruit?.draw()

    }

}